package com.example.yiqiuser.controller;
import com.example.yiqiuser.entity.Help;
import com.example.yiqiuser.service.HelpService;
import com.example.yiqiuser.util.Page;
import com.example.yiqiuser.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: yiqiuser
 * @description:
 * @author: 诸葛龙辰
 * @create: 2023-04-01 10:55
 * @version:
 **/
@RestController
@RequestMapping("help")
public class HelpController extends BaseController {
    /**
     * 依赖注入
     */
    @Resource
    private HelpService helpService;
    /**
     * 分页带参查询
     * @param page
     * @return
     */
    @PostMapping("queryPage")
    public Result queryPage(@RequestBody Page<Help> page){
        return success(helpService.queryPage(page));
    }

    /**
     * 查询全部
     * @return
     */
    @PostMapping("queryAll")
    public  Result queryAll(){
        return success(helpService.queryAll());
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @GetMapping("queryById")
    public Result queryById(Integer id){
        return success(helpService.queryById(id));
    }

    /**
     * 添加
     * @param help
     * @return
     */
    @PostMapping("add")
    public  Result add(@RequestBody Help help){
        return success(helpService.add(help));
    }

    /**
     * 更改
     * @param help
     * @return
     */
    @PostMapping("update")
    public Result update(@RequestBody Help help){
        return success(helpService.update(help));
    }

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @GetMapping("deleteById")
    public Result deleteById(Integer id){
        return success(helpService.deleteById(id));
    }
}
